import {Body, Controller, Post, UsePipes, ValidationPipe} from '@nestjs/common'
import {CreateUserDto} from './dto/create-user.dto'
import {ClassValidationPipe} from './customPipes/class-validation.pipe'

@Controller('user')
// @UsePipes(new ValidationPipe())     //控制器级别的管道
export class UserController {
    @Post('create')
    // @UsePipes(new ClassValidationPipe())
    // async createMethod(@Body(new ClassValidationPipe()) userDto: CreateUserDto) {
    async createMethod(@Body() userDto: CreateUserDto) {
        console.log('createMethod',userDto)
        return userDto;
    }

    @Post('create2')
    // @UsePipes(new ClassValidationPipe())
    // userDto类型是Object就不需要校验 metatype类型
    async createMethod2(@Body() userDto: Object) {
        return userDto;
    }

    @Post('create3')
    // @UsePipes(new ClassValidationPipe())
    // userDto类型是Object就不需要校验 metatype类型
    async createMethod3(@Body() userDto: CreateUserDto) {
        return userDto;
    }
}
